import time

from selenium import webdriver
from selenium.webdriver.chrome.options import Options  # 用于设置谷歌浏览器
from selenium.webdriver.chrome.service import Service  # 用于管理驱动
from selenium.webdriver.common.by import By


# 创建设置浏览器对象
def open_browser():
    o_llq = Options()
    o_llq.add_argument('--no-sandbox')
    o_llq.add_experimental_option('detach', True)
    llq = webdriver.Chrome(service=Service(r'D:\software\chromedriver-win64\chromedriver.exe'), options=o_llq)
    return llq


llq = open_browser()
llq.get('https://sahitest.com/demo/promptTest.htm')
llq.implicitly_wait(10)
llq.find_element(By.XPATH, '/html/body/form/input[1]').click()

time.sleep(3)
# 提示框-有一个确定按钮和取消按钮，还可以输入内容

# 弹窗输入内容
llq.switch_to.alert.send_keys('cat是猫，dog是狗')

# 确定
llq.switch_to.alert.accept()




